package com.x.crm.dao;

import com.x.crm.model.FollowAppoint;
import com.x.crm.model.FollowUp;
import com.x.framework.dao.BaseDao;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class FollowAppointDao extends BaseDao{


	private final static String baseSelectFollowAppointListSql = "SELECT * FROM  CRM_FOLLOW_APPOINTMENT  I " +
			"WHERE 1=1 ";

	public List<FollowAppoint> selectFollowAppointList(FollowAppoint followAppoint) throws Exception {
		StringBuilder sb = new StringBuilder(baseSelectFollowAppointListSql);
		List<Object> params = new ArrayList<Object>();
		searchBasicCondition(followAppoint, sb, params);
		sb.append(" ORDER BY I.APPOINT_CREATE_TIME DESC");
		return this.queryForList(sb.toString(), FollowAppoint.class, params, followAppoint);
	}


	private void searchBasicCondition(FollowAppoint followAppoint, StringBuilder sb, List<Object> params) {
		if (this.isString(followAppoint.getIntentionId())) {
			sb.append("AND I.INTENTION_ID = ? ");
			params.add(followAppoint.getIntentionId());
		}
	}


}
